package com.example.shilehui;

import cn.jhc.service.SearchService;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

public class SearchCityActivity extends Activity implements OnClickListener {
	
	
	private ImageView _titleLeftImageView;
	private TextView _titleMiddleTextView;
	private TextView _titleRightTextView;
	private TextView _allTextView;
	private ImageView _allImageView;
	private Activity _searchProvinceActivity;
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);	
		ini();
	}
	
	
	private void ini(){
		
		setContentView(R.layout.search_city_layout);
		setTitleStyle();
		setPageStyle();
		
	}
	
	private void setTitleStyle(){
		
		_titleLeftImageView=(ImageView)findViewById(R.id.search_district_title_left_imageview);
		_titleMiddleTextView=(TextView)findViewById(R.id.search_district_title_middle_textview);
		_titleRightTextView=(TextView)findViewById(R.id.search_district_title_right_textview);
		
		_titleMiddleTextView.setText(getResources().getString(R.string.select_city));
		_titleMiddleTextView.setTextColor(Color.WHITE);
		_titleMiddleTextView.setTextSize(18);
		
		_titleRightTextView.setText(getResources().getString(R.string.confirm));
		_titleRightTextView.setTextColor(Color.WHITE);
		_titleRightTextView.setTextSize(16);
		
		_titleLeftImageView.setOnClickListener(this);
		_titleRightTextView.setOnClickListener(this);
		
	}
	
	private void setPageStyle(){
		
		_allTextView=(TextView)findViewById(R.id.search_city_all_textview);
		_allImageView=(ImageView)findViewById(R.id.search_city_all_imageview);
		
		_allTextView.setText(getResources().getString(R.string.all));
		_allTextView.setTextColor(Color.BLACK);
		
		SearchService.getInstance().setAllCityImageView(_allImageView);
		
		_allTextView.setOnClickListener(this);
		_allImageView.setOnClickListener(this);
		
	}


	@Override
	public void onClick(View v) {
		
		switch (v.getId()) {
		case R.id.search_district_title_left_imageview:
			
			
			
			finish();	
			break;
		
		case R.id.search_district_title_right_textview:
			
			_searchProvinceActivity=SearchService.getInstance().getSearchProvinceActivity();
			_searchProvinceActivity.finish();
			finish();
			
			break;
			
		case R.id.search_city_all_textview:
			
			SearchService.getInstance().SetCityPosition(99999999);
			refresh();
			
			break;
		
		case R.id.search_city_all_imageview:
			
			SearchService.getInstance().SetCityPosition(99999999);
			refresh();
			
			break;
		

		default:
			break;
		}
		
		
		
	}
	
	
	
	
	
	

	private void refresh() {    
        onCreate(null);
	}
	

}
